package com.py.payment.controller;

import com.py.payment.entity.PyInvestment;
import com.py.payment.entity.PyUnit;
import com.py.payment.service.PyInvestmentService;
import com.py.payment.service.PyUnitService;
import com.py.payment.tools.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/investment")
@CrossOrigin(origins = "*")
public class InvestmentController {

    @Autowired
    private PyInvestmentService investmentService;

    @Autowired
    private PyUnitService unitService;

    @PostMapping(name = "获取单位列表",path = "/getUnitList")
    public ResponseData getUnitList(){
        List<PyUnit> unitList = this.unitService.list();
        return ResponseData.success(unitList);
    }

    @PostMapping(name = "保存",path = "/saveInvestment")
    public ResponseData saveInvestment(@RequestBody PyInvestment investment) {
        investment.setCreateTime(new Date());
        this.investmentService.save(investment);
        return ResponseData.success();
    }

}
